# $ID$
# Maintainer: Rémy Oudompheng <remy@archlinux.org>

pkgname=perl-unicode-linebreak
_dist=Unicode-LineBreak
pkgver=2019.001
pkgrel=4
pkgdesc="UAX #14 Unicode Line Breaking Algorithm"
arch=('x86_64')
url="https://metacpan.org/release/${_dist}"
license=('PerlArtistic' 'GPL')
depends=('perl' 'perl-mime-charset' 'libthai')
checkdepends=('perl-test-pod')
options=('!emptydirs')
source=(https://cpan.metacpan.org/authors/id/N/NE/NEZUMI/${_dist}-${pkgver}.tar.gz
        LineBreakTest-8.0.0.txt::https://www.unicode.org/Public/8.0.0/ucd/auxiliary/LineBreakTest.txt
        GraphemeBreakTest-8.0.0.txt::https://www.unicode.org/Public/8.0.0/ucd/auxiliary/GraphemeBreakTest.txt)
# Checksums from https://cpan.metacpan.org/authors/id/N/NE/NEZUMI/CHECKSUMS
md5sums=('003d6da7a13700e069afed9238c864b9'
         '8bd863892b8b963331779873130ae45a'
         '4356c6f90a74769e2d82487a01822cab')
sha256sums=('486762e4cacddcc77b13989f979a029f84630b8175e7fef17989e157d4b6318a'
            '149b14ab93b06c887a958fb16d0ad01193063ef69cc14f10338ae4d0accd6c28'
            '0cedd6e0f5cadf57ce9cfc96beccfd083b0faa0809a631a777cd25f0316bfabb')

prepare() {
    # Copy Unicode 8.0 test files. Later versions do not pass.
    cp -av "${srcdir}/LineBreakTest-8.0.0.txt" "${srcdir}/${_dist}-${pkgver}/test-data/LineBreakTest.txt"
    cp -av "${srcdir}/GraphemeBreakTest-8.0.0.txt" "${srcdir}/${_dist}-${pkgver}/test-data/GraphemeBreakTest.txt"
}

build() {
    cd "${srcdir}/${_dist}-${pkgver}"
    unset PERL5LIB PERL_MM_OPT PERL_MB_OPT PERL_LOCAL_LIB_ROOT
    export PERL_MM_USE_DEFAULT=1 PERL_AUTOINSTALL=--skipdeps
    perl Makefile.PL
    make
}

check() {
    cd "${srcdir}/${_dist}-${pkgver}"
    unset PERL5LIB PERL_MM_OPT PERL_MB_OPT PERL_LOCAL_LIB_ROOT
    export PERL_MM_USE_DEFAULT=1
    make test
}

package() {
    cd "${srcdir}/${_dist}-${pkgver}"
    unset PERL5LIB PERL_MM_OPT PERL_MB_OPT PERL_LOCAL_LIB_ROOT
    make install INSTALLDIRS=vendor DESTDIR="$pkgdir"
}
